package annotation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;

import javax.annotation.Resource;

public class Zoo {
//    @Autowired(required = false)    //使用自动装填来配置是，可以通过 required 来设置来云逊该值为空
    @Resource(name = "tiger1")
    private Tiger tiger;

//    @Autowired
    @Resource(type = Monkey.class)  //通过 Resource 来自动注入，这个是 J2EE 的方法，比 AutoWired 更优秀，减低耦合
    private Monkey monkey;

    public void say() {
        tiger.say();
        monkey.say();
    }
}
